<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../../vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- 实例内容 -->
        {{message}}
        <parent-Com :mydata="message"></parent-Com>
    </div>

    <template id="parentCom">
      <div>
        <h1>这是父组件{{mydata}}</h1>
        <button @click="changebtn">点击父组件修改数据</button>
        <Childcom :mystr="mydata"></Childcom>
      </div>
    </template>
    <template id="Childcom">
      <div>
        <h1>这是子组件{{mystr}}</h1>
      </div>
    </template>
    <script>
        let Childcom = {
            props: ["mystr"],
            template: "#Childcom",
            data() {
                return {
                    message: "子组件数据",
                };
            },
        };

        let parentCom = {
            props: {
                mydata: {
                    type: String,
                    default: "默认值",
                },
                num: {
                    type: Number,
                },
            },
            components: {
                Childcom,
            },
            template: "#parentCom",

            deta() {
                return {
                    message: "这是父组件",
                    mydatas: this.mydata,
                };
            },
            methods: {
                changebtn() {
                    // console.log(11);
                    console.log(this.mydatas);
                },
            },
        };

        new Vue({
            el: "#app",
            components: {
                parentCom,
            },
            data: {
                message: "实例化",
            },
        });
    </script>
</body>

</html>